//
//  PlainController.m
//  youthNote
//
//  Created by huangrensheng on 15/12/29.
//  Copyright © 2015年 laber. All rights reserved.
//

#import "PlainController.h"
#import "PlainCollectionCell.h"

@interface PlainController ()<UICollectionViewDataSource,UICollectionViewDelegate>

@property (nonatomic, strong) UICollectionView *plainCollec;

@end

@implementation PlainController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor lightGrayColor];
    [self createWithLeftStyle:nil middleStyle:@{@"type":@"title",@"title":@"话题"} rightStyle:nil];
    
    UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
    self.plainCollec.userInteractionEnabled = YES;
    self.plainCollec = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
    self.plainCollec.backgroundColor = BACK_COLOR;
    [self.plainCollec registerClass:[PlainCollectionCell class] forCellWithReuseIdentifier:@"PlainCollectionCell"];
    self.plainCollec.delegate = self;
    self.plainCollec.dataSource = self;
    [self.view addSubview:self.plainCollec];
    [self.plainCollec mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
}

#pragma mark UICollectionViewDelegate
- (NSInteger)collectionView:( UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 30;
}

-(NSInteger )numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1 ;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    CGFloat width =  (SCREEN_WIDTH-5)/4;
    
    return CGSizeMake(width, width+width/3);
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 1;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
    return 1;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    PlainCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"PlainCollectionCell" forIndexPath:indexPath];
    return cell;
}

//显示时调用
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(nonnull UICollectionViewCell *)cell forItemAtIndexPath:(nonnull NSIndexPath *)indexPath{
    
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
